package com.frxuexi.lib_base.room

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update

@Dao
interface LeaveDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun addLeave(leave: Leave):Long

    @Query("select * from leave where status=:status order by startTime desc")
    fun selectNoApprove(status:String):List<Leave>

    @Query("select * from leave where uid=:uid order by startTime asc limit (:page-1)*:size,:page*:size")
    fun selectLeavesByUid(uid:Int,page:Int,size:Int):List<Leave>

    @Query("select count(*) from leave where uid=:uid")
    fun getCount(uid:Int):Int

    @Update
    fun update(leave: Leave):Int

}